<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<body>

    <script src="/static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        // IAM服务地址
        var iamUrl = "https://iamtest.by.gov.cn:8083";
        // 客户端Id，由IAM侧分配
        var clientId = "IoT";
        // IoT首页地址，可根据项目情况修改
        var IoTUrl = "https://183.2.142.146:44380/index.html%23/Index";
        $(function() {
            $.ajax({
                type: "GET",
                async: false,
                url: "/IOT/huawei/IAM/V1/oauth/ActionAuthChain?redirctToPath=" + iamUrl,
                success: function(data) {
                    console.log(data);
                    if (data.code == 200) {
                        window.location.href = iamUrl + "/idp/oauth2/authorize?state=1&client_id=" + clientId + "&response_type=code&redirect_uri=" + IoTUrl;
                    } else {
                        window.location.href = "/index.html#/Login";
                    }
                },
                error: function(e) {
                    console.log(e);
                    window.location.href = "/index.html#/Login";
                }
            });
        });
    </script>
</body>

</html>